package components
{
	import UIFree.uif_component;
	
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	public class c_pcomponent extends c_control {
		public function c_pcomponent(parent:uif_component, styleClass:Object='') {
			var inner: Rectangle = getPortRect(parent);
			super(parent, inner.x, inner.y, inner.width, inner.height, styleClass);
		}
		
		protected function getPortRect(a_parent: uif_component=null): Rectangle {
			return (a_parent?a_parent:parentComponent).getInner(0, 0, -1, -1);
		}
		
		override protected function listenEvents():void {
			super.listenEvents();
			addEvent(uif_component.RESIZE, doParentResize, parent);
		}
		
		protected function doParentResize(e: Event): void {
			updateBoundsFromParent();
		}		
		
		protected function updateBoundsFromParent(): void {
			var inner: Rectangle = getPortRect(parentComponent);
			setRect(inner);
		}
	}
}